﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EncuentraWEB
{
    public partial class Formulario_web13 : System.Web.UI.Page
    {
        public decimal[,] _puntos = new decimal[0,2] ;
        int _totalPuntos = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            var sUser = (string)Session["User"];
            if (sUser != "admin")
            {
                Response.Redirect("~\\default.aspx");
                return;
            }
            if (!this.IsPostBack)
            {
                //var obj = new clsLineas();
                //dropLineas.DataSource = obj.buscar(0,"");
                //dropLineas.DataTextField = "varDenominacion";
                //dropLineas.DataValueField = "intIdLinea";
                //dropLineas.DataBind();
                this.txtRecorrido.Text = Request.QueryString["Recorrido"];
                
            }
            var scriptPopUp = new System.Text.StringBuilder();
            scriptPopUp.Append("PABLO();");
            ScriptManager.RegisterStartupScript(this, this.GetType(), "VENTANAPopUp", scriptPopUp.ToString(), true);
            
     
            

            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //var objRecorrido = new clsRecorridos();
            //objRecorrido.intidRecorrido = Convert.ToInt32(Request.QueryString["Recorrido"]);
            //DataTable dt = objRecorrido.Recorrido();
            //decimal lat = 0;
            //decimal lng = 0;
            //foreach (DataRow dr in dt.Rows)
            //{
            //    lat = Convert.ToDecimal(dr["decLatitud"]);
            //    lng = Convert.ToDecimal(dr["decLongitud"]);
            //    AgregarPunto(lat, lng);
            //}
            var scriptPopUp = new System.Text.StringBuilder();
            scriptPopUp.Append("cargar();");
            ScriptManager.RegisterStartupScript(this, this.GetType(), "CARGAR", scriptPopUp.ToString(), true);
       
        }
        public decimal[,] Puntos
        {
            get { return _puntos; }
            set { _puntos = value; }
        }
        private  void AgregarPunto(decimal lat, decimal lng)
         {
            _totalPuntos++;
            decimal[,] newArray = new decimal[_totalPuntos, 2];
            Array.Copy(_puntos,newArray,_puntos.Length);
            _puntos = newArray;
            _puntos[_totalPuntos-1, 0] = lat;
            _puntos[_totalPuntos-1, 1] = lng;
         }

    

        protected void Button3_Click(object sender, EventArgs e)
        {
            var scriptPopUp = new System.Text.StringBuilder();
            scriptPopUp.Append("cargar12();");
            ScriptManager.RegisterStartupScript(this, this.GetType(), "CARGAR", scriptPopUp.ToString(), true);
        }
    }

  

    
    
}
